package day10;

public class demo1 {
    public static void main(String[] args) {

    }

    public int getLongestPalindrome (String A) {
        int n=A.length();
        int ret=1;
        for (int i = 1; i <n ; i++) {
            int left=i-1;
            int right=i+1;
            while (left>=0&&right<=n-1&&A.charAt(left)==A.charAt(right)){
                ret=Math.max(ret,right-left+1);
                left--;
                right++;
            }
            left=i;
            right=i+1;
            while (left>=0&&right<=n-1&&A.charAt(left)==A.charAt(right)){
                ret=Math.max(ret,right-left+1);
                left--;
                right++;
            }
        }
        return ret;
    }
}
